package cn.hsa.xxx.bookData.dto;


import cn.hsa.xxx.api.dto.BookTypeDTO;
import cn.hsa.xxx.bookData.entity.BookTypeDO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

@Component
public class BookTypeDTOConverter {

    /**
     * Convert BookTypeDTO to BookTypeDO
     *
     * @param bookTypeDTO
     * @return
     */
    public BookTypeDO convertToBookTypeDO(BookTypeDTO bookTypeDTO) {
        if (bookTypeDTO == null) {
            return null;
        }
        BookTypeDO bookTypeDO = new BookTypeDO();

        //BookTypeDO.setId(BookTypeDTO.getId());
        //BookTypeDO.setName(BookTypeDTO.getName());
        //BookTypeDO.setSex(BookTypeDTO.getSex());
        //BookTypeDO.setAddr(BookTypeDTO.getAddr());

        //性能略差，但使用方便
        BeanUtils.copyProperties(bookTypeDTO, bookTypeDO);

        return bookTypeDO;
    }

    /**
     * Convert BookTypeDO to BookTypeDTO
     *
     * @param bookTypeDO
     * @return
     */
    public BookTypeDTO convertToBookTypeDTO(BookTypeDO bookTypeDO) {
        if (bookTypeDO == null) {
            return null;
        }

        BookTypeDTO bookTypeDTO = new BookTypeDTO();

        //BookTypeDTO.setId(BookTypeDO.getId());
        //BookTypeDTO.setName(BookTypeDO.getName());
        //BookTypeDTO.setSex(BookTypeDO.getSex());
        //BookTypeDTO.setAddr(BookTypeDO.getAddr());

        //性能略差，但使用方便
        BeanUtils.copyProperties(bookTypeDO, bookTypeDTO);

        return bookTypeDTO;
    }
}
